package netty.inboundhandlerandoutboundhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @author 帅小伙
 * @date 2022/1/21
 * @description
 * handler 会标识 入站的handler还是出站的handler
 */
public class MyServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        System.out.println("ChannelInitializer 执行了");
        ChannelPipeline pipeline = ch.pipeline();
        // 入站handler进行解码
        pipeline.addLast(new MyByteToLongDecoder2());
        pipeline.addLast(new MyLongToByteEncoder());
        // 处理业务逻辑
        pipeline.addLast(new MyServerHandler());
    }
}
